package proxypattern.entity;

import proxypattern.base.IGumballMachineRemote;
import util.DateUtil;
import java.io.Serializable;
import java.rmi.RemoteException;

/**糖果机监控器
 * @author yaojianfeng
 */
public class GumballMonitor implements Serializable {
    private static final long serialVersionUID = 984531362316L;
    private IGumballMachineRemote machine;

    public GumballMonitor(IGumballMachineRemote machine) {
        this.machine = machine;
    }

    public void report(){
        System.out.println(DateUtil.timeStamp2DateString(System.currentTimeMillis(), "yyyy-MM-dd hh:mm:ss"));
        try {
            System.out.println("糖果机的位置" + machine.getLocation());
            System.out.println("糖果库存" + machine.getCount());
            System.out.println("当前状态:" + machine.getState().getDesc());
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
